using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using ViewOnAddInsAPI.HostContract.Media;
using ViewOnAddInsAPI.Device;
using ViewOnAddInsAPI.HostContract.Tasks;

#region Copyright (c) 2006, 2007, 2008 ViewOn Media Services. All rights reserved.

/*
 Copyright (c) 2006, 2007, 2008 ViewOn Media Services. All rights reserved.
 This work is copyrighted in its entirety. Permission to use "ViewOn.tv"
 material may be granted only after we receive a written request from you,
 and you receive written permission from us.

 While ViewOn Media Services provides the information herein to anyone,
 we retain copyright on all code, text, graphic images, and other content.
 This means that you may not distribute the code, the text or graphics to others without the
 express written permission of ViewOn Media Services; "mirror" this information on your server
 without our permission; or modify or reuse the code, text or graphics on our servers.
 You may print copies of the information for your own personal use; and, you may reference
 the Service from your own documents. Any commercial use of this material is prohibited without
 the written permission of ViewOn Media Services. In all copies of this information, you must
 retain this notice and any other copyright notices originally included with such information.

 This material may be protected by U.S. and International Copyright laws, and you are legally
 bound by the copyright notices on those systems.

 "ViewOn" logos and other official symbols or graphics may not be used in connection with any
 product or service that has not been expressly authorized in advance in writing or in any manner
 that is likely to cause confusion among the users of this or other Web sites or among the public.
 All other seals, graphics or trademarks of organizations not affiliated with ViewOn Media Services
 that appear on this site are the property of their respective owners.

 ViewOn Media Services reserve all other rights. 
*/

#endregion

#region ViewOn.tv Source Code Licence

/*
This license governs use of the ViewOn.tv software. If you use the software, you accept this license. If you do not accept the license, do not use the software.

1. Summary

The source code is made available to view for reference purposes or to contribute to the project only. Developers may not distribute or modify the code for commercial or non-commercial purposes without express Agreement of View On Media Services.

2. Definitions

The terms "reproduce," "reproduction," and "distribution" have the same meaning here as under U.S. copyright law.
"Licensor" means the company "ViewOn Media Services".
"You" means the licensee of the software, who is not engaged in designing, developing, or testing other software, that has the same or substantially the same features or functionality as the software.
"Your company" means the company you worked for when you downloaded the software.
"Reference use" means use of the software within your company as a reference, in read only form, for the sole purposes of debugging and maintaining your products. For clarity, "reference use" does NOT include (a) the right to use the software for purposes of designing, developing, or testing other software, that has the same or substantially the same features or functionality as the software, and (b) the right to distribute the software outside of your company.
"Licensed patents" means any Licensor patent claims which read directly on the software as distributed by the Licensor under this license.

3. Grant of Rights

(A) Copyright Grant- Subject to the terms of this license, the Licensor grants you a non-transferable, non-exclusive, worldwide, royalty-free copyright license to reproduce the software for reference use.
(B) Patent Grant- Subject to the terms of this license, the Licensor grants you a non-transferable, non-exclusive, worldwide, royalty-free patent license under licensed patents for reference use.
4. Limitations
(A) No Trademark License- This license does not grant you any rights to use the Licensor's name, logo, or trademarks.
(B) If you begin patent litigation against the Licensor over patents that you think may apply to the software (including a cross-claim or counterclaim in a lawsuit), your license to the software ends automatically.
(C) The software is licensed "as-is." You bear the risk of using it. The Licensor gives no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the Licensor excludes the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
 */

#endregion

namespace ViewOnAddInsAPI.HostContract
{
    public delegate void MediasOperationHandler(MediaDeviceFeature feature, MediaDeviceFeatureItem featureItem, MediaOperationKind operationKind, List<MediaData> medias);

    public interface IMediaService
    {

        #region Events

        //---- Devices events
        event EventHandler MediaDeviceActivation;

        //---- Media events
        event EventHandler MediaSelectionChanged;
        event EventHandler PlayerStatusChanged;

        event EventHandler MediaDataConnected;
        event EventHandler MediaDataCannotConnect;

        event MediasOperationHandler MediasOperation;

        #endregion

        #region Properties

        /// <summary>
        /// Returns a reference to the current media device.
        /// </summary>
        MediaDeviceAddIn CurrentMediaDevice
        {
            get;
        }

        /// <summary>
        /// Returns a reference to the current media device feature.
        /// </summary>
        MediaDeviceFeature CurrentMediaDeviceFeature
        {
            get;
        }

        /// <summary>
        /// Returns a reference to the current media device feature item.
        /// </summary>
        MediaDeviceFeatureItem CurrentMediaDeviceFeatureItem
        {
            get;
        }

        /// <summary>
        /// Returns a reference to the current media.
        /// </summary>
        MediaData CurrentMedia
        {
            get;
        }

        /// <summary>
        /// Returns the total time of the current media.
        /// </summary>
        TimeSpan TotalTime
        {
            get;
        }

        /// <summary>
        /// Returns if the application volume is muted or not.
        /// </summary>
        bool IsMuted
        {
            get;
        }

        /// <summary>
        /// Returns the application sound volume.
        /// </summary>
        int Volume
        {
            get;
            set;
        }

        /// <summary>
        /// Returns the current media position.
        /// </summary>
        float Position
        {
            get;
            set;
        }

        /// <summary>
        /// Returns the status of the internal playing engine.
        /// </summary>
        MediaPlayStatus MediaPlayStatus
        {
            get;
        }

        /// <summary>
        /// Determine or set if we are in a shuffle mode.
        /// </summary>
        bool IsShuffleMode
        {
            get;
            set;
        }

        /// <summary>
        /// Determine or set if we are in a repeat mode.
        /// </summary>
        bool IsRepeatMode
        {
            get;
            set;
        }

        /// <summary>
        /// Returns the music files extensions
        /// </summary>
        Dictionary<string, string> SupportedMusicExtensions
        {
            get;
        }

        /// <summary>
        /// Returns the radio files extensions
        /// </summary>
        Dictionary<string, string> SupportedRadioExtensions
        {
            get;
        }

        /// <summary>
        /// Returns the video files extensions
        /// </summary>
        Dictionary<string, string> SupportedVideoExtensions
        {
            get;
        }

        #endregion

        #region Next / Previous

        void NextMedia();

        void PreviousMedia();

        #endregion

        #region Play/Stop/Pause....

        void Stop();

        void Play();

        void PlayMedia(MediaData mediaData);

        void MuteInverse();

        void ShuffleInverse();

        void RepeatInverse();

        #endregion

        #region Notify...

        /// <summary>
        /// Notify an event related to medias.
        /// </summary>
        /// <param name="feature"></param>
        /// <param name="featureItem"></param>
        /// <param name="operation"></param>
        /// <param name="medias"></param>
        void NotifyOperation(MediaDeviceFeature feature, MediaDeviceFeatureItem featureItem, MediaOperationKind operation, List<MediaData> medias);

        #endregion

        #region Media copy management

        /// <summary>
        /// Register a class able to handle the "copy" of some media datas.
        /// </summary>
        /// <param name="handler">The handler to register</param>
        void RegisterCopyHandler(MediaDataCopyHandler handler);

        #endregion

        #region RemoveMediaDatas

        /// <summary>
        /// Remove some MediaData from a feature or feature's item.
        /// </summary>
        /// <param name="mediaDatas">The media data to remove</param>
        /// <param name="mediaDeviceFeature">The feature</param>
        /// <param name="mediaDeviceItem">The feature item</param>
        /// <param name="parentFolder">The media data's parent folder</param>
        void RemoveMediaDatas(List<MediaData> mediaDatas, MediaDeviceFeature mediaDeviceFeature, MediaDeviceFeatureItem mediaDeviceItem, MediaFolder parentFolder);

        #endregion

        #region UpdateMediaDatas

        /// <summary>
        /// Update a media data.
        /// </summary>
        /// <param name="mediaDatas">The MediaData instance</param>
        /// <param name="mediaDeviceFeature">The associated feature</param>
        /// <param name="field">The field identifying the information to update</param>
        /// <param name="newValue">The value</param>
        void UpdateMediaDatas(List<MediaData> mediaDatas, MediaDeviceFeature mediaDeviceFeature, MediaDataTagField field, object newValue);

        #endregion

        #region CreateTask

        /// <summary>
        /// This method create a "task" related to medias.
        /// </summary>
        /// <param name="taskType">The type of the task</param>
        /// <param name="parameters">Some optional parameters, each task has its own set of parameters</param>
        /// <returns>Returns the task</returns>
        Task CreateTask(MediaServiceTasks taskType, params object[] parameters);

        #endregion

        #region IsSupported...

        /// <summary>
        /// Returns true if ViewOn.tv support this kind of musical file.
        /// </summary>
        /// <param name="filePath">The file path</param>
        /// <returns>true if we support this kind of file</returns>
        bool IsSupportedMusicFile(string filePath);

        /// <summary>
        /// Returns true if ViewOn.tv support this kind of online radio file.
        /// </summary>
        /// <param name="filePath">The file path</param>
        /// <returns>true if we support this kind of file</returns>
        bool IsSupportedRadioFile(string filePath);

        /// <summary>
        /// Returns true if ViewOn.tv support this kind of video file.
        /// </summary>
        /// <param name="filePath">The file path</param>
        /// <returns>true if we support this kind of file</returns>
        bool IsSupportedVideoFile(string filePath);

        #endregion

        #region Helpers : Find...

        /// <summary>
        /// Search for a device feature based on its handle.
        /// </summary>
        /// <param name="handle">The device feature handle to search</param>
        /// <returns>Returns null or the device feature</returns>
        MediaDeviceFeature FindDeviceFeatureByHandle(string handle);

        #endregion

        #region Helpers : Tag ...

        /// <summary>
        /// Extract a bitmap from a file.
        /// </summary>
        /// <param name="filePath">The file path</param>
        /// <returns>The extracted bitmap</returns>
        Bitmap TagExtractBitmap(string filePath);

        /// <summary>
        /// Create a picture information from the bitmap.
        /// </summary>
        /// <param name="bitmap">The bitmap to analyse</param>
        /// <returns>Returns an object containing the information.</returns>
        object TagCreatePictureInformation(Bitmap bitmap);

        /// <summary>
        /// Save the picture to file from its information object.
        /// </summary>
        /// <param name="pictureInformation">The object containing the information</param>
        /// <param name="filePath">The path to the target file</param>
        void TagSaveImageInformation(object pictureInformation, string filePath);

        #endregion

    }

    #region enum : MediaDataTagField

    // Used to identify each field in the tag.
    public enum MediaDataTagField
    {
        All,
        Image,
        Title,
        Artist,
        Album,
        Composer,
        TrackCount,
        Year,
        Comment,
        Genre,
        Genres,
        Rating,
        FrontCoverPicture,
        Track,
        Path,
        MetaTags,
        Director,
        Languages,
        Casts,
        Traillers,
        Companies,
        Duration,
        ReleaseDate,
        PlotOutline
    }

    #endregion

    #region enum : MediaOperationKind

    public enum MediaOperationKind
    {
        Loaded,
        Imported,
        Added,
        Removed,
        Renamed,
        Updated,
        Moved
    }

    #endregion

    #region enum : PlayerStatus

    public enum MediaPlayStatus
    {
        Play,
        Paused,
        Stopped
    }

    #endregion

    #region enum : MediaServiceTasks

    public enum MediaServiceTasks
    {
        RipMusicCD
    }

    #endregion

}
